﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using PS.Practices.SiteBuilder.Features.Schema.DOM;

namespace PS.Practices.Provisioner.Provisioner.Schema.Logic
{
    public interface IVisitorContext
    {
        IWebOperationVisitor WebOperationVisitor { get; }
        Dictionary<string, object> Properties { get; } 
        //IListOperationVisitor ListOperationVisitor { get; }

        void Finalize();
    }


#region Object Model Visitor Interfaces

    // TODO put visitor calls here?
    public class OmVisitorContext : IVisitorContext
    {
        public OmVisitorContext(SPWeb web, Dictionary<string, object> properties)
        {
            Properties = properties; 
            WebOperationVisitor = new OmWebOperationVisitor(web, properties);
        }

        //public OmVisitorContext(SPList list, SPWeb web)
        //{
        //    ListOperationVisitor = new OmListOperationVisitor(list, web);
        //}

        public Dictionary<string, object> Properties { get; private set; }

        public IWebOperationVisitor WebOperationVisitor { get; private set;}

        //public IListOperationVisitor ListOperationVisitor
        //{
        //    get;
        //    private set;
        //}

        public void Finalize()
        {
        }
    }

    public interface IListOperationVisitor
    {
        void Visit(SetSendToLocation setSendToLocation);
        void Visit(List list);
        void Visit(UpdateTitle updateTitle);
        void Visit(UpdateFields updateFields);
        void Visit(ReorderCTypes reorderCTypes);
        void Visit(RemoveCTypes removeCTypes);
        void Visit(ListItem listItem);
        void Visit(FixupView fixupView);
        void Visit(FixupACL fixupACL);
        void Visit(AddFields addFields);
        void Visit(AddCTypes addCTypes);
    }

    public interface IWebOperationVisitor : IDisposable
    {
        object ReplaceLiveFields(string val);
        void Visit(ProvisionerRoot provisionerRoot);
        void Visit(RestrictSiteTemplates action);
        void Visit(WebProperies action);
        void Visit(FixupWebACL fixupWebAcl);
        void Visit(SetStyling setStyling);
        void Visit(WebFeatures webFeatures);
        void Visit(User user);
        void Visit(SiteGroup siteGroup);
        void Visit(PrincipalRole principalRole);
        void Visit(File file);
        void Visit(FbaRole fbaRole);
        void Visit(AssociateSiteGroup associateSiteGroup);
        void Visit(ProvisionWebs provisionWebs);
        void Visit(ProvisionLists provisionLists);
        void Visit(CustomizedCssFiles customizedCssFiles);
        void Visit(FixupLists fixupLists);
        void Visit(AddMembersToSiteGroup addMembersToSiteGroup);
    }

#endregion 
}
